package file;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;

public class Demo12 {
    public static void main(String[] args) {
        try(OutputStream outputStream = new FileOutputStream("test2.txt")){
            //此处的PrintWriter的用法就和System.out是一样的了
            PrintWriter printWriter = new PrintWriter(outputStream);
            printWriter.println("hello");//文件没有改变，等待更正 写到缓冲区
            printWriter.flush();//更正，通过flush把缓冲区的东西写入


        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
